﻿@page
@model IndexModel
@{
    ViewData["Title"] = "首页";
}
<form>
    <div class="row">
        <div class="col">
        </div>
        <div class="col-5">
            <div class="input-group mb-3">

                <input type="text" class="form-control" aria-describedby="basic-addon2" asp-for="SearchString">
                <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="submit" id="button-addon2">找一找</button>
                </div>

            </div>
        </div>
        <div class="col">
        </div>

    </div>
</form>
<div class="alert alert-danger" role="alert">
    本站所有书籍均收集自互联网，仅供学习和研究使用，请不要用于商业用途。
</div>
<div class="row">
    @if (Model.Book.Count > 0)
    {
        <div class="col-6">
            <ul class="list-group list-group-flush">
                @for (var i = 0; i < Model.Book.Count; i++)
                {
                    if (i % 2 == 0)
                    {
                        <li class="list-group-item">
                            <div class="row">
                                <div class="col-2   text-end">
                                    <div class="bookcover">
                                        @*   <img src="@Model.Book[i].ImageUrl" class="mr-3 img-thumbnail" alt="@Model.Book[i].Title">*@
                                    </div>
                                </div>
                                <div class="col-10">
                                    <h5 class="mt-0 mb-1">《@Model.Book[i].Title》</h5>
                                    <p>@Model.Book[i].Author |@Model.Book[i].ReleaseDate |@Model.Book[i].Genre  |<a asp-page="./Books/Details" asp-route-id="@Model.Book[i].Id">下载传送</a> </p>
                                </div>
                            </div>
                        </li>
                    }
                }
            </ul>
        </div>
        <div class="col-6">
            <ul class="list-group list-group-flush">
                @for (var i = 0; i < Model.Book.Count; i++)
                {
                    if (i % 2 == 1)
                    {
                        <li class="list-group-item">
                            <div class="row">
                                <div class="col-2 text-end">
                                    <div class="bookcover">
                                        @* <img src="@Model.Book[i].ImageUrl" class="mr-3 img-thumbnail" alt="@Model.Book[i].Title">*@
                                    </div>
                                </div>
                                <div class="col-10">
                                    <h5 class="mt-0 mb-1">《@Model.Book[i].Title》</h5>
                                    <p>@Model.Book[i].Author |@Model.Book[i].ReleaseDate |@Model.Book[i].Genre  |<a asp-page="./Books/Details" asp-route-id="@Model.Book[i].Id">下载传送</a> </p>
                                </div>
                            </div>
                        </li>
                    }
                }
            </ul>
        </div>
    }
    else
    {
        <p style="text-align:center">没有找到书籍信息!!!</p>
    }

</div>
@{
    var prevDisabled = !Model.Book.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.Book.HasNextPage ? "disabled" : "";
}

<div class="text-center">
    <a asp-page="./Index" asp-route-pageIndex="@(Model.Book.PageIndex - 1)" asp-route-searchString="@Model.SearchString" class="btn btn-primary @prevDisabled">
        上一页
    </a>
    <a asp-page="./Index" asp-route-pageIndex="@(Model.Book.PageIndex + 1)" asp-route-searchString="@Model.SearchString" class="btn btn-primary @nextDisabled">
        下一页
    </a>

</div>